package com.org.base.ctrl;

import android.app.Activity;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.net.ConnectivityManager;
import android.os.Bundle;

import com.org.base.util.ConnectionChangeReceiver;
import com.org.zp.app.RecApp;

public abstract class BaseActivity extends Activity {

	private ConnectionChangeReceiver receiver;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	}

	@Override
	protected void onResume() {
		super.onResume();
		IntentFilter filter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
        receiver = new ConnectionChangeReceiver();
        this.registerReceiver(receiver, filter);
	}

	@Override
	protected void onPause() {
		super.onPause();
		if (receiver != null) {
			this.unregisterReceiver(receiver);
		}
	}


	protected SharedPreferences getPreferences() {
		return getSharedPreferences(Constant.PREFERENCE_NAME, Activity.MODE_PRIVATE);
	}

	protected RecApp getMyApplication() {
		return (RecApp) getApplication();
	}
	
	/** 调用此方法来返回上一个界面 */
	public void goback(String name){
		ActivityTaskManager.getInstance().removeActivity(name);
	}
}
